import ZHRequest from './request/index'
import { BASE_URL, TIME_OUT } from './request/config'
import localCaches from '@/utils/caches'
const zhRequest = new ZHRequest({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
  interceptors: {
    requestInterceptors: (config) => {
      const token = localCaches.getcache('token')
      if (token) {
        if (config.headers) {
          config.headers.Authorization = `Bearer ${token}`
        }
      }
      return config
    },
    requestInterceptorCatch: (error) => {
      return error
    },
    responseInterceptorCatch: (error) => {
      return error
    },
    responsetInterceptors: (res) => {
      return res
    }
  }
})
export default zhRequest
